home *** CD-ROM | disk | FTP | other *** search
Modula Implementation | 1997-04-25 | 26.9 KB | 693 lines | [TEXT/3PRM] |
- implementation module deltaDialog;
-
-
- import StdClass;
- import StdInt, StdBool, StdString;
- from deltaMenu import EnableMenuSystem, DisableMenuSystem;
- from windows import SelectWindow;
- from menus import EnableItem, DisableItem, CheckItem;
- from OS_utilities import SysBeep;
- from dialogs import GetDItem, SetIText;
- import dialogAccess, dialogDevice, dialogUpdate, dialogAbout, dialogInternal;
-
-
- :: DialogChange *s :== (DialogState s (IOState s)) -> DialogState s (IOState s);
-
- DeltaDialogError :: String String -> .x;
- DeltaDialogError f error = Error f "deltaDialog" error;
-
-
- /* Opening/Closing of dialogs and notices. A beep is a very simple notice. */
-
- OpenDialog :: !(DialogDef s (IOState s)) !(IOState s) -> IOState s;
- OpenDialog (AboutDialog _ _ _ _) io = io;
- OpenDialog dDef io
- | id == AboutDialogID = io;
- | modalActive && alreadyOpen = io`;
- | modalActive = IOStateAddInactiveDialog dRep1 io2;
- | alreadyOpen = IOStateSetDialogs dialogs` io3;
- = IOStateAddDialog dRep3 io4;
- where {
- (modalActive, ptr, io1) = IOStateModalDialogActive io;
- (dialogs, io`) = IOStateGetDialogs io1;
- id = GetDialogDefId dDef;
- (alreadyOpen,_) = GetDialog id dialogs;
- (tb, io``) = IOStateGetToolbox io`;
- (dRep1,tb1) = OpenAnyDialog Modeless ptr dDef tb;
- io2 = IOStateSetToolbox tb1 io``;
- (_,dialogs`) = SetDialogInFront id dialogs;
- io3 = IOStateSetToolbox (ActivateDialog dialogs` tb) io``;
- (dRep3,tb3) = OpenAnyDialog Modeless (-1) dDef tb;
- io4 = IOStateSetToolbox (ForceDialogUpdate dRep3 tb3) io``;
- };
-
- OpenModalDialog :: !(DialogDef *s (IOState *s)) !*s !(IOState *s) -> (!*s, !IOState *s);
- OpenModalDialog dDef s io = DoModalDialog dDef s io;
-
- CloseDialog :: !DialogId !(IOState s) -> IOState s;
- CloseDialog id io
- | not found = io`;
- = DeactivateDialog dRep io`;
- where {
- (found, dRep, io`) = IOStateRemoveDialog id io;
- };
-
- CloseActiveDialog :: !(IOState s) -> IOState s;
- CloseActiveDialog io = DeviceCloseDialog io;
-
- OpenNotice :: !NoticeDef !*s !(IOState *s) -> (!NoticeButtonId, !*s, !IOState *s);
- OpenNotice notice s io
- = (buttonid,s,io`)
- where {
- (buttonid,io`) = DoNotice notice io;
- };
-
- Beep :: !(IOState s) -> IOState s;
- Beep io = IOStateChangeToolbox (SysBeep 1) io;
-
-
- /* Get(Active)DialogInfo returns the DialogInfo for the indicated dialog.
- The boolean indicates whether the indicated dialog exists. When it is False
- a dummy DialogInfo is returned. */
-
- GetDialogInfo :: !DialogId !(IOState s) -> (!Bool, !DialogInfo, !IOState s);
- GetDialogInfo id io = IOStateGetDialogInfo id io;
-
- GetActiveDialogInfo :: !(IOState s) -> (!Bool, !DialogInfo, !IOState s);
- GetActiveDialogInfo io = IOStateGetActiveDialogInfo io;
-
-
- /* Enabling/Disabling of dialog items */
-
- EnableDialogItems :: ![DialogItemId] !(DialogState s (IOState s)) -> DialogState s (IOState s);
- EnableDialogItems itids dstate
- = CreateDialogState (SetDialogItemsAbility Able itids (UnpackDialogState dstate));
-
- DisableDialogItems :: ![DialogItemId] !(DialogState s (IOState s)) -> DialogState s (IOState s);
- DisableDialogItems itids dstate
- = CreateDialogState (SetDialogItemsAbility Unable itids (UnpackDialogState dstate));
-
- SetDialogItemsAbility :: !SelectState ![DialogItemId] !(!DialogRep s (IOState s), !Toolbox)
- -> (!DialogRep s (IOState s), !Toolbox);
- SetDialogItemsAbility abty ids ((DialogH i t m r popups items f, ptr), tb)
- = ((DialogH i t m r popups items1 f, ptr), tb1);
- where {
- (items1, tb1) = SetItemsAbility popups abty ids items ptr 1 tb;
- };
-
- SetItemsAbility :: ![PopUpHandle] !SelectState ![DialogItemId] ![DialogItem s (IOState s)]
- !DialogPtr !Int !Toolbox -> (![DialogItem s (IOState s)], !Toolbox);
- SetItemsAbility _ _ [] items _ _ tb
- = (items, tb);
- SetItemsAbility pps abty ids [but=:DialogButton id ps tt ab bf : rest] ptr nr tb
- | not toBeSet || SelectStateEqual abty ab
- = ([but : setrest], tb1);
- = ([DialogButton id ps tt abty bf : setrest], ToggleHilite abty ptr nr tb1);
- where {
- (setrest, tb1) = SetItemsAbility pps abty ids` rest ptr (inc nr) tb;
- (toBeSet, ids`) = RemoveCheckInt ids id;
- };
- SetItemsAbility pps abty ids [RadioButtons id ps rc di buts : rest] ptr nr tb
- = ([RadioButtons id ps rc di buts` : setrest], tb2);
- where {
- (ids`,buts`,nr`,tb1)= SetRadioButtonsAbility abty ids buts ptr nr tb;
- (setrest, tb2) = SetItemsAbility pps abty ids` rest ptr nr` tb1;
- };
- SetItemsAbility pps abty ids [CheckBoxes id ps rc boxes : rest] ptr nr tb
- = ([CheckBoxes id ps rc boxes` : setrest], tb2);
- where {
- (ids`,boxes`,nr`,tb1) = SetCheckBoxesAbility abty ids boxes ptr nr tb;
- (setrest,tb2) = SetItemsAbility pps abty ids` rest ptr nr` tb1;
- };
- SetItemsAbility pps abty ids [icon=:DialogIconButton id pos dom look ab bf : rest] ptr nr tb
- | not toBeSet || SelectStateEqual abty ab
- = ([icon : setrest], tb1);
- = ([DialogIconButton id pos dom look abty bf : setrest], tb2);
- where {
- (setrest,tb1) = SetItemsAbility pps abty ids` rest ptr nr tb;
- tb2 = RedrawIconOrControl pos dom (look abty) ptr tb1;
- (toBeSet, ids`) = RemoveCheckInt ids id;
- };
- SetItemsAbility pps abty ids [ctrl=:Control id pos dom ab state look cf df : rest] ptr nr tb
- | not toBeSet || SelectStateEqual abty ab
- = ([ctrl : setrest], tb1);
- = ([Control id pos dom abty state look cf df : setrest], tb2);
- where {
- (setrest,tb1) = SetItemsAbility pps abty ids` rest ptr nr tb;
- tb2 = RedrawIconOrControl pos dom (look abty state) ptr tb1;
- (toBeSet,ids`) = RemoveCheckInt ids id;
- };
- SetItemsAbility popups abty ids [popup=:DialogPopUp id ps ab di pitems : rest] ptr nr tb
- | not toBeSet || SelectStateEqual abty ab
- = ([DialogPopUp id ps ab di pitems` : setrest], tb2);
- = ([DialogPopUp id ps abty di pitems` : setrest], tb3);
- where {
- (ids``,pitems`,tb1) = SetPopUpItemsAbility abty ids pitems menu 1 tb;
- (setrest,tb2) = SetItemsAbility popups abty ids`` rest ptr nr tb1;
- tb3 = DrawPopUpAbility ps abty ptr tb2;
- (toBeSet,ids`) = RemoveCheckInt ids id;
- (pi,menu) = GetPopUpHandle id popups;
- };
- SetItemsAbility pps abty ids [item : rest] ptr nr tb
- = ([item : setrest], tb`);
- where {
- (setrest, tb`) = SetItemsAbility pps abty ids rest ptr (inc nr) tb;
- };
- SetItemsAbility _ _ _ items _ _ tb = (items, tb);
-
- SetPopUpItemsAbility :: !SelectState ![DialogItemId] ![RadioItemDef s (IOState s)]
- !MacMenuHandle !Int !Toolbox
- -> (![DialogItemId], ![RadioItemDef s (IOState s)], !Toolbox);
- SetPopUpItemsAbility abty ids [item=:RadioItem id tt ab df : rest] menu nr tb
- | not toBeSet || SelectStateEqual abty ab
- = (ids``,[item:rest`],tb`);
- = (ids``,[RadioItem id tt abty df : rest`],SetMenuItemAbility abty menu nr tb`);
- where {
- (ids``,rest`,tb`) = SetPopUpItemsAbility abty ids` rest menu (inc nr) tb;
- (toBeSet, ids`) = RemoveCheckInt ids id;
- };
- SetPopUpItemsAbility _ ids items _ _ tb = (ids,items,tb);
-
- SetRadioButtonsAbility :: !SelectState ![DialogItemId] ![RadioItemDef s (IOState s)]
- !DialogPtr !Int !Toolbox
- -> (![DialogItemId], ![RadioItemDef s (IOState s)], !Int, !Toolbox);
- SetRadioButtonsAbility abty ids [but=:RadioItem id tt ab df : rest] ptr nr tb
- | not toBeSet || SelectStateEqual abty ab
- = (ids``,[but:rest`],nr`,tb`);
- = (ids``,[RadioItem id tt abty df : rest`],nr`,ToggleHilite abty ptr nr tb`);
- where {
- (ids``,rest`,nr`,tb`) = SetRadioButtonsAbility abty ids` rest ptr (inc nr) tb;
- (toBeSet, ids`) = RemoveCheckInt ids id;
- };
- SetRadioButtonsAbility _ ids [] _ nr tb = (ids,[],nr,tb);
-
- SetCheckBoxesAbility :: !SelectState ![DialogItemId] ![CheckBoxDef s (IOState s)]
- !DialogPtr !Int !Toolbox
- -> (![DialogItemId], ![CheckBoxDef s (IOState s)], !Int, !Toolbox);
- SetCheckBoxesAbility abty ids [but=:CheckBox id tt ab ms df : rest] ptr nr tb
- | not toBeSet || SelectStateEqual abty ab
- = (ids``,[but:rest`],nr`,tb`);
- = (ids``,[CheckBox id tt abty ms df : rest`],nr`,ToggleHilite abty ptr nr tb`);
- where {
- (ids``,rest`,nr`,tb`) = SetCheckBoxesAbility abty ids` rest ptr (inc nr) tb;
- (toBeSet,ids`) = RemoveCheckInt ids id;
- };
- SetCheckBoxesAbility _ ids [] _ nr tb = (ids,[],nr,tb);
-
- SetMenuItemAbility :: !SelectState !MacMenuHandle !Int !Toolbox -> Toolbox;
- SetMenuItemAbility Able menu nr tb = EnableItem menu nr tb;
- SetMenuItemAbility Unable menu nr tb = DisableItem menu nr tb;
-
- ToggleHilite :: !SelectState !DialogPtr !Int !Toolbox -> Toolbox;
- ToggleHilite Able ptr nr tb = Unhilite ptr nr tb;
- ToggleHilite Unable ptr nr tb = Hilite ptr nr tb;
-
-
- /* Marking/Unmarking of check boxes. */
-
- MarkCheckBoxes :: ![DialogItemId] !(DialogState s (IOState s)) -> DialogState s (IOState s);
- MarkCheckBoxes itids dstate
- = CreateDialogState (SetCheckBoxesMark Mark itids (UnpackDialogState dstate));
-
- UnmarkCheckBoxes :: ![DialogItemId] !(DialogState s (IOState s)) -> DialogState s (IOState s);
- UnmarkCheckBoxes itids dstate
- = CreateDialogState (SetCheckBoxesMark NoMark itids (UnpackDialogState dstate));
-
- SetCheckBoxesMark :: !MarkState ![DialogItemId] !(!DialogRep s (IOState s),!Toolbox)
- -> (!DialogRep s (IOState s),!Toolbox);
- SetCheckBoxesMark mark ids ((DialogH i t m r p items f, ptr), tb)
- = ((DialogH i t m r p items1 f, ptr), tb1);
- where {
- (items1,tb1) = SetMark mark ids items ptr 1 tb;
- };
-
- SetMark :: !MarkState ![DialogItemId] ![DialogItem s (IOState s)] !DialogPtr !Int !Toolbox
- -> (![DialogItem s (IOState s)], !Toolbox);
- SetMark _ [] items _ _ tb = (items,tb);
- SetMark mark ids [CheckBoxes id ps rc boxes : rest] ptr nr tb
- = ([CheckBoxes id ps rc boxes` : setrest], tb2);
- where {
- (ids`,boxes`,nr`,tb1) = CheckBoxesMark mark ids boxes ptr nr tb;
- (setrest,tb2) = SetMark mark ids` rest ptr nr` tb1;
- };
- SetMark mark ids [item=: RadioButtons id ps rc di buts : rest] ptr nr tb
- = ([item : setrest],tb1);
- where {
- (setrest,tb1) = SetMark mark ids rest ptr (nr+Length_new buts) tb;
- };
- SetMark mark ids [popup=:DialogPopUp id ps ab di bs : rest] ptr nr tb
- = ([popup : setrest],tb1);
- where {
- (setrest,tb1) = SetMark mark ids rest ptr nr tb;
- };
- SetMark mark ids [icon=:DialogIconButton id pos dom look ab bf : rest] ptr nr tb
- = ([icon : setrest],tb1);
- where {
- (setrest,tb1) = SetMark mark ids rest ptr nr tb;
- };
- SetMark mark ids [ctrl=:Control id pos dom ab state look cf df : rest] ptr nr tb
- = ([ctrl : setrest], tb1);
- where {
- (setrest,tb1) = SetMark mark ids rest ptr nr tb;
- };
- SetMark mark ids [item : rest] ptr nr tb
- = ([item : setrest], tb1);
- where {
- (setrest,tb1) = SetMark mark ids rest ptr (inc nr) tb;
- };
- SetMark _ _ items _ _ tb = (items,tb);
-
- CheckBoxesMark :: !MarkState ![DialogItemId] ![CheckBoxDef s (IOState s)] !DialogPtr !Int !Toolbox
- -> (![DialogItemId], ![CheckBoxDef s (IOState s)], !Int, !Toolbox);
- CheckBoxesMark mark ids [but=:CheckBox id tt ab ms df : rest] ptr nr tb
- | not to_be_set || MarkEqual mark ms
- = (ids``,[but:rest`],nr`,tb1);
- | Checked mark
- = (ids``,[but` : rest`],nr`,SetCtlValue h 1 tb2);
- = (ids``,[but` : rest`],nr`,SetCtlValue h 0 tb2);
- where {
- (ids``,rest`,nr`,tb1) = CheckBoxesMark mark ids` rest ptr (inc nr) tb;
- (it,h,r,tb2) = GetDItem ptr nr tb1;
- but` = CheckBox id tt ab mark df;
- (to_be_set,ids`) = RemoveCheckInt ids id;
- };
- CheckBoxesMark _ ids items _ nr tb = (ids,items,nr,tb);
-
-
- /* Press a radio button (and unpress the rest). */
-
- SelectDialogRadioItem :: !DialogItemId !(DialogState s (IOState s)) -> DialogState s (IOState s);
- SelectDialogRadioItem itid dstate
- = CreateDialogState (PressRadioBut itid (UnpackDialogState dstate));
-
- PressRadioBut :: !DialogItemId !(DialogRep s (IOState s), !Toolbox)
- -> (!DialogRep s (IOState s), !Toolbox);
- PressRadioBut id ((DialogH i t m r popups items f, ptr), tb)
- = ((DialogH i t m r popups items1 f, ptr), tb1);
- where {
- (items1,tb1) = PressRadio popups id items ptr 1 tb;
- };
-
- PressRadio :: ![PopUpHandle] !DialogItemId ![DialogItem s (IOState s)] !DialogPtr !Int !Toolbox
- -> (![DialogItem s (IOState s)],!Toolbox);
- PressRadio popups rid [popup=:DialogPopUp id pos ab di pits : rest] ptr nr tb
- | not in_group
- = ([popup : rest1],tb1);
- = ([DialogPopUp id pos ab rid pits : rest], tb2);
- where {
- (in_group,onr,inr,title)= InDialogPopUpMenu 0 0 "" di rid pits 1;
- (rest1,tb1) = PressRadio popups rid rest ptr nr tb;
- tb2 = RedrawPopUpItemText pos title ptr
- (CheckItem menu inr True
- (CheckItem menu onr False tb1));
- (pi,menu) = GetPopUpHandle id popups;
- };
- PressRadio pps rid [item=:RadioButtons id ps rc di buts : rest] ptr nr tb
- | not in_group
- = ([item : rest1], tb1);
- = ([RadioButtons id ps rc rid buts : rest], tb2);
- where {
- (rest1,tb1) = PressRadio pps rid rest ptr nr` tb;
- tb2 = UpdateRadioButtons rid buts ptr nr tb;
- (in_group,nr`) = InRadioGroup rid buts nr;
- };
- PressRadio pps rid [item=: CheckBoxes id ps rc boxes : rest] ptr nr tb
- = ([item : rest1],tb1);
- where {
- (rest1,tb1) = PressRadio pps rid rest ptr (nr+Length_new boxes) tb;
- };
- PressRadio pps rid [icon=:DialogIconButton id pos dom look ab bf : rest] ptr nr tb
- = ([icon : rest1],tb1);
- where {
- (rest1,tb1) = PressRadio pps rid rest ptr nr tb;
- };
- PressRadio pps rid [ctrl=:Control id pos dom ab state look cf df : rest] ptr nr tb
- = ([ctrl : rest1],tb1);
- where {
- (rest1,tb1) = PressRadio pps rid rest ptr nr tb;
- };
- PressRadio pps rid [item : rest] ptr nr tb
- = ([item : rest1],tb1);
- where {
- (rest1,tb1) = PressRadio pps rid rest ptr (inc nr) tb;
- };
- PressRadio _ _ items _ _ tb = (items,tb);
-
- InDialogPopUpMenu :: !Int !Int !ItemTitle !DialogItemId !DialogItemId ![RadioItemDef s (IOState s)]
- !Int
- -> (!Bool, !Int, !Int, !ItemTitle);
- InDialogPopUpMenu oldnr newnr title oldid newid [RadioItem id tt ab df : rest] inr
- | newmatch && oldnr > 0 = (True,oldnr,inr,tt);
- | oldmatch && newnr > 0 = (True,inr,newnr,title);
- | newmatch = InDialogPopUpMenu oldnr inr tt oldid newid rest (inc inr);
- | oldmatch = InDialogPopUpMenu inr newnr title oldid newid rest (inc inr);
- = InDialogPopUpMenu oldnr newnr title oldid newid rest (inc inr);
- where {
- newmatch = id == newid;
- oldmatch = id == oldid;
- };
- InDialogPopUpMenu _ _ _ _ _ _ _ = (False,0,0,"");
-
- UpdateRadioButtons :: !DialogItemId ![RadioItemDef s (IOState s)] !DialogPtr !Int !Toolbox -> Toolbox;
- UpdateRadioButtons rid [RadioItem id tt ab df : rest] ptr nr tb
- | rid == id = UpdateRadioButtons rid rest ptr (inc nr) (SetCtlValue h 1 tb1);
- = UpdateRadioButtons rid rest ptr (inc nr) (SetCtlValue h 0 tb1);
- where {
- (it,h,r,tb1) = GetDItem ptr nr tb;
- };
- UpdateRadioButtons _ _ _ _ tb = tb;
-
- InRadioGroup :: !DialogItemId ![RadioItemDef s (IOState s)] !Int -> (!Bool, !Int);
- InRadioGroup id1 [RadioItem id2 tt ab df : rest] nr
- | id1 == id2 = (True,nr);
- = InRadioGroup id1 rest (inc nr);
- InRadioGroup _ _ nr = (False,nr);
-
-
- /* Change the contents of an editable or a dynamic text field. */
-
- ChangeEditText :: !DialogItemId !String !(DialogState s (IOState s)) -> DialogState s (IOState s);
- ChangeEditText itid text dstate = ChangeDialogItem itid (ChangeEText text) dstate;
-
- ChangeEText :: !String !DialogPtr !Int !(!DialogItem s (IOState s),!Toolbox)
- -> (!DialogItem s (IOState s), !Toolbox);
- ChangeEText text ptr nr (EditText id ps wd nl _,tb)
- = (EditText id ps wd nl text, SetIText h text tb1);
- where {
- (it,h,r,tb1) = GetDItem ptr nr tb;
- };
- ChangeEText _ _ _ item_tb = item_tb;
-
- ChangeDynamicText :: !DialogItemId !String !(DialogState s (IOState s)) -> DialogState s (IOState s);
- ChangeDynamicText itid text dstate = ChangeDialogItem itid (ChangeDText text) dstate;
-
- ChangeDText :: !String !DialogPtr !Int !(!DialogItem s (IOState s),!Toolbox)
- -> (!DialogItem s (IOState s), !Toolbox);
- ChangeDText text ptr nr (DynamicText id ps wd _, tb)
- = (DynamicText id ps wd text, SetIText h text tb1);
- where {
- (it,h,r,tb1) = GetDItem ptr nr tb;
- };
- ChangeDText _ _ _ item_tb = item_tb;
-
-
- /* Change the IconLook and redraw the IconButton */
-
- ChangeIconLook :: !DialogItemId !IconLook !(DialogState s (IOState s)) -> DialogState s (IOState s);
- ChangeIconLook itid ilook dstate = ChangeDialogItem itid (SetIconLook ilook) dstate;
-
- SetIconLook :: !IconLook !DialogPtr !Int !(!DialogItem s (IOState s),!Toolbox)
- -> (!DialogItem s (IOState s), !Toolbox);
- SetIconLook ilook ptr nr (DialogIconButton id pos dom look abty bf,tb)
- = (DialogIconButton id pos dom ilook abty bf, RedrawIconOrControl pos dom (ilook abty) ptr tb);
- SetIconLook _ _ _ item_tb = item_tb;
-
-
- /* Change the ControlState and redraw the Control */
-
- ChangeControlState :: !DialogItemId !ControlState !(DialogState s (IOState s))
- -> DialogState s (IOState s);
- ChangeControlState cid cstate dstate = ChangeDialogItem cid (SetControlState cstate) dstate;
-
- SetControlState :: !ControlState !DialogPtr !Int !(!DialogItem s (IOState s),!Toolbox)
- -> (!DialogItem s (IOState s), !Toolbox);
- SetControlState cstate ptr nr (Control id pos dom ab state look cf df,tb)
- = (Control id pos dom ab cstate look cf df,RedrawIconOrControl pos dom (look ab cstate) ptr tb);
- SetControlState _ _ _ item_tb = item_tb;
-
-
- /* Change the ControlLook and redraw the Control */
-
- ChangeControlLook :: !DialogItemId !ControlLook !(DialogState s (IOState s))
- -> DialogState s (IOState s);
- ChangeControlLook cid clook dstate = ChangeDialogItem cid (SetControlLook clook) dstate;
-
- SetControlLook :: !ControlLook !DialogPtr !Int !(!DialogItem s (IOState s),!Toolbox)
- -> (!DialogItem s (IOState s), !Toolbox);
- SetControlLook clook ptr nr (Control id pos dom ab state look cf df,tb)
- = (Control id pos dom ab state clook cf df,RedrawIconOrControl pos dom (clook ab state) ptr tb);
- SetControlLook _ _ _ item_tb = item_tb;
-
-
- /* Change the ControlFeel, but dont redraw the Control */
-
- ChangeControlFeel :: !DialogItemId !ControlFeel !(DialogState s (IOState s))
- -> DialogState s (IOState s);
- ChangeControlFeel cid cfeel dstate = ChangeDialogItem cid (SetControlFeel cfeel) dstate;
-
- SetControlFeel :: !ControlFeel !DialogPtr !Int !(!DialogItem s (IOState s),!Toolbox)
- -> (!DialogItem s (IOState s), !Toolbox);
- SetControlFeel cfeel ptr nr (Control id pos dom ab cs cl _ df,tb)
- = (Control id pos dom ab cs cl cfeel df, tb);
- SetControlFeel _ _ _ item_tb = item_tb;
-
-
- /* Change the DialogFunction of a check box, a radio button or a user-defined control. */
-
- ChangeDialogFunction :: !DialogItemId !(DialogFunction s (IOState s)) !(DialogState s (IOState s))
- -> DialogState s (IOState s);
- ChangeDialogFunction itid dfunc dstate
- = CreateDialogState (SetDFunction itid dfunc (UnpackDialogState dstate));
-
- SetDFunction :: !DialogItemId !(DialogFunction s (IOState s)) !(!DialogRep s (IOState s),!Toolbox)
- -> (!DialogRep s (IOState s),!Toolbox);
- SetDFunction id dfunc ((DialogH i t m r p items f, ptr), tb)
- = ((DialogH i t m r p (SetDFunc id dfunc items) f, ptr), tb);
-
- SetDFunc :: !DialogItemId !(DialogFunction s (IOState s)) ![DialogItem s (IOState s)]
- -> [DialogItem s (IOState s)];
- SetDFunc itid dfunc [item=:DialogPopUp id ps ab di pits : rest]
- | found = [DialogPopUp id ps ab di pits` : rest];
- = [item : SetDFunc itid dfunc rest];
- where {
- (found, pits`) = SetRadioItemsDFunc itid dfunc pits;
- };
- SetDFunc itid dfunc [item=:CheckBoxes id ps rc boxes : rest]
- | found = [CheckBoxes id ps rc boxes` : rest];
- = [item : SetDFunc itid dfunc rest];
- where {
- (found,boxes`) = SetCheckBoxesDFunc itid dfunc boxes;
- };
- SetDFunc itid dfunc [item=:RadioButtons id ps rc di buts : rest]
- | found = [RadioButtons id ps rc di buts` : rest];
- = [item : SetDFunc itid dfunc rest];
- where {
- (found,buts`) = SetRadioItemsDFunc itid dfunc buts;
- };
- SetDFunc itid dfunc [item=:Control id ps pd ab cs cl cf _ : rest]
- | itid == id = [Control id ps pd ab cs cl cf dfunc : rest];
- = [item : SetDFunc itid dfunc rest];
- SetDFunc itid dfunc [item : rest]
- = [item : SetDFunc itid dfunc rest];
- SetDFunc _ _ items = items;
-
- SetCheckBoxesDFunc :: !DialogItemId !(DialogFunction s (IOState s)) ![CheckBoxDef s (IOState s)]
- -> (!Bool, ![CheckBoxDef s (IOState s)]);
- SetCheckBoxesDFunc itid dfunc [box=:CheckBox id tt ab ms df : rest]
- | itid == id = (True, [CheckBox id tt ab ms dfunc : rest]);
- = (found, [box : rest`]);
- where {
- (found,rest`) = SetCheckBoxesDFunc itid dfunc rest;
- };
- SetCheckBoxesDFunc _ _ items = (False,items);
-
- SetRadioItemsDFunc :: !DialogItemId !(DialogFunction s (IOState s)) ![RadioItemDef s (IOState s)]
- -> (!Bool, ![RadioItemDef s (IOState s)]);
- SetRadioItemsDFunc itid dfunc [but=:RadioItem id tt ab df : rest]
- | itid == id = (True, [RadioItem id tt ab dfunc : rest]);
- = (found, [but : rest`]);
- where {
- (found,rest`) = SetRadioItemsDFunc itid dfunc rest;
- };
- SetRadioItemsDFunc _ _ items = (False,items);
-
-
- /* Change the ButtonFunction of a DialogButton or DialogIconButton. */
-
- ChangeButtonFunction :: !DialogItemId !(ButtonFunction s (IOState s)) !(DialogState s (IOState s))
- -> DialogState s (IOState s);
- ChangeButtonFunction itid bfunc dstate = ChangeDialogItem itid (SetButtonFunction bfunc) dstate;
-
- SetButtonFunction :: !(ButtonFunction s (IOState s)) !DialogPtr !Int
- !(!DialogItem s (IOState s),!Toolbox)
- -> (!DialogItem s (IOState s),!Toolbox);
- SetButtonFunction bfunc ptr nr (DialogButton id ps tt ab _,tb)
- = (DialogButton id ps tt ab bfunc,tb);
- SetButtonFunction bfunc ptr nr (DialogIconButton id ps pd il ab _,tb)
- = (DialogIconButton id ps pd il ab bfunc,tb);
- SetButtonFunction _ _ _ item_tb = item_tb;
-
-
- /* Change Set/Reset button function of a PropertyDialog. The id of the Set button
- is always -1, the id of the Reset button is always -2 (see dialogDef.icl). */
-
- ChangeSetFunction :: !(SetFunction s (IOState s)) !(DialogState s (IOState s))
- -> DialogState s (IOState s);
- ChangeSetFunction setfunc dstate = ChangeButtonFunction (-1) setfunc dstate;
-
- ChangeResetFunction :: !(ResetFunction s (IOState s)) !(DialogState s (IOState s))
- -> DialogState s (IOState s);
- ChangeResetFunction resetfunc dstate = ChangeButtonFunction (-2) resetfunc dstate;
-
-
- /* DialogStateGetDialogInfo returns the DialogInfo corresponding to
- the DialogState given to it. */
-
- DialogStateGetDialogInfo :: !(DialogState s (IOState s))
- -> (!DialogInfo, !DialogState s (IOState s));
- DialogStateGetDialogInfo dState
- = (DialogHandleToDialogInfo dH, CreateDialogState (dRep1,tb1));
- where {
- (dRep1,tb1) = RetrieveEditTexts (UnpackDialogState dState);
- (dH,_) = dRep1;
- };
-
-
- /* Functions that retrieve information from the DialogInfo. */
-
- GetEditText :: !DialogItemId !DialogInfo -> String;
- GetEditText tid dinfo
- = RetrieveEditText tid edits;
- where {
- (edits,_,_,_) = DialogInfoToItemInfo dinfo;
- };
-
- RetrieveEditText :: !DialogItemId ![(DialogItemId,String)] -> String;
- RetrieveEditText tid [(id,text):rest]
- | id == tid = text;
- = RetrieveEditText tid rest;
- RetrieveEditText tid _
- = DeltaDialogError "GetEditText" ("No EditText item found with id " +++ toString tid);
-
- GetSelectedRadioItemId :: !DialogItemId !DialogInfo -> DialogItemId;
- GetSelectedRadioItemId tid dinfo
- = RetrieveRadioItemId tid radios;
- where {
- (_,radios,_,_) = DialogInfoToItemInfo dinfo;
- };
-
- RetrieveRadioItemId :: !DialogItemId ![(DialogItemId,DialogItemId)] -> DialogItemId;
- RetrieveRadioItemId tid [(id,di):rest]
- | id == tid = di;
- = RetrieveRadioItemId tid rest;
- RetrieveRadioItemId tid _
- = DeltaDialogError "GetSelectedRadioItemId"
- ("No RadioButtons or DialogPopUp item found with id " +++ toString tid);
-
- CheckBoxesMarked :: !DialogItemId !DialogInfo -> [(DialogItemId,Bool)];
- CheckBoxesMarked tid dinfo
- = RetrieveCheckMarks tid checks;
- where {
- (_,_,checks,_) = DialogInfoToItemInfo dinfo;
- };
-
- RetrieveCheckMarks :: !DialogItemId ![(DialogItemId,[(DialogItemId,Bool)])] -> [(DialogItemId,Bool)];
- RetrieveCheckMarks tid [(id,boxes):rest]
- | id == tid = boxes;
- = RetrieveCheckMarks tid rest;
- RetrieveCheckMarks tid _
- = DeltaDialogError "CheckBoxesMarked" ("No CheckBoxes item found with id " +++ toString tid);
-
- CheckBoxMarked :: !DialogItemId !DialogInfo -> Bool;
- CheckBoxMarked tid dinfo
- = RetrieveCheckMark tid checks;
- where {
- (_,_,checks,_) = DialogInfoToItemInfo dinfo;
- };
-
- RetrieveCheckMark :: !DialogItemId ![(DialogItemId,[(DialogItemId,Bool)])] -> Bool;
- RetrieveCheckMark tid [(id,boxes):rest]
- | found = mark;
- = RetrieveCheckMark tid rest;
- where {
- (found,mark) = FindCheckMark tid boxes;
- };
- RetrieveCheckMark tid _
- = DeltaDialogError "CheckBoxMarked" ("No CheckBox item found with id " +++ toString tid);
-
- FindCheckMark :: !DialogItemId ![(DialogItemId,Bool)] -> (Bool,Bool);
- FindCheckMark tid [(id,mark):rest]
- | id == tid = (True,mark);
- = FindCheckMark tid rest;
- FindCheckMark _ _ = (False,False);
-
- GetControlState :: !DialogItemId !DialogInfo -> ControlState;
- GetControlState tid dinfo
- = RetrieveControlState tid ctrls;
- where {
- (_,_,_,ctrls) = DialogInfoToItemInfo dinfo;
- };
-
- RetrieveControlState :: !DialogItemId ![(DialogItemId,ControlState)] -> ControlState;
- RetrieveControlState tid [(id,state):rest]
- | id == tid = state;
- = RetrieveControlState tid rest;
- RetrieveControlState tid _
- = DeltaDialogError "GetControlState" ("No Control item found with id " +++ toString tid);
-
-
- /* Change the dialog with the specified id according to the list of change functions. */
-
- ChangeDialog :: !DialogId ![DialogChange s] !(IOState s) -> IOState s;
- ChangeDialog did changes ioState
- | not found = ioState1;
- = IOStateReplaceDialog did drep1 (IOStateSetToolbox tb1 ioState2);
- where {
- (found,drep,ioState1) = IOStateGetDialog did ioState;
- (tb, ioState2) = IOStateGetToolbox ioState1;
- (drep1,tb1) = UnpackDialogState (ApplyDialogChanges changes (CreateDialogState (drep,tb)));
- };
-
- ApplyDialogChanges :: ![DialogChange s] !(DialogState s (IOState s)) -> DialogState s (IOState s);
- ApplyDialogChanges [change : rest] dstate = ApplyDialogChanges rest (change dstate);
- ApplyDialogChanges _ dstate = dstate;
-
-
- //
- // Change a dialog item according to the function (used internally)
- //
-
- :: ItemChange *s
- :== DialogPtr -> Int
- -> (DialogItem s (IOState s),!Toolbox)
- -> (DialogItem s (IOState s),!Toolbox);
-
-
- ChangeDialogItem :: !DialogItemId !(ItemChange *s) !(DialogState *s (IOState *s))
- -> DialogState *s (IOState *s);
- ChangeDialogItem itid change dstate
- = CreateDialogState (ChangeDItem itid change (UnpackDialogState dstate));
-
- ChangeDItem :: !DialogItemId !(ItemChange *s) !(!DialogRep *s (IOState *s),!Toolbox)
- -> (!DialogRep *s (IOState *s),!Toolbox);
- ChangeDItem id change ((DialogH i t m r p items f, ptr), tb)
- = ((DialogH i t m r p items1 f, ptr), tb1);
- where {
- (items1,tb1) = ChangeItem id ptr 1 change items tb;
- };
-
- ChangeItem :: !DialogItemId !DialogPtr !Int !(ItemChange *s) ![DialogItem *s (IOState *s)] !Toolbox
- -> (![DialogItem *s (IOState *s)],!Toolbox);
- ChangeItem itid ptr nr change [item : items] tb
- | itid == id
- = ([item` : items],tb1);
- = ([item : items1],tb2);
- where {
- (item`,tb1) = change ptr nr (item,tb);
- (id,add) = GetDialogItemId item;
- (items1,tb2)= ChangeItem itid ptr (nr + add) change items tb;
- };
- ChangeItem _ _ _ _ [] tb = ([],tb);
-
- GetDialogItemId :: !(DialogItem s (IOState s)) -> (!DialogItemId, Int);
- GetDialogItemId (DialogButton id _ _ _ _) = (id,1);
- GetDialogItemId (DialogIconButton id _ _ _ _ _) = (id,0);
- GetDialogItemId (StaticText id _ _) = (id,1);
- GetDialogItemId (DynamicText id _ _ _) = (id,1);
- GetDialogItemId (EditText id _ _ _ _) = (id,1);
- GetDialogItemId (DialogPopUp id _ _ _ _) = (id,0);
- GetDialogItemId (CheckBoxes id _ _ boxes) = (id,Length_new boxes);
- GetDialogItemId (RadioButtons id _ _ _ buts) = (id,Length_new buts);
- GetDialogItemId (Control id _ _ _ _ _ _ _) = (id,0);
- GetDialogItemId _ = DeltaDialogError "GetDialogItemId" "Unknown item";
-